package common.mq.master.service.impl;

import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import common.mq.master.service.IMasterService;
import common.mq.po.MessType;
import common.mq.po.Message;
import common.mq.po.Queue;

public class MasterServiceImpl implements IMasterService {

	private Map<Integer, Queue> queues = new ConcurrentHashMap<Integer, Queue>(); // queueId-queue
																					// queueId,consumerId一致
	
	public MasterServiceImpl(){
		Queue q = new Queue();
		q.setId(1);
		Map<String, Message> waitArea = new HashMap<String, Message>();
		q.setWaitArea(waitArea );
		Message m = new Message();
		m.setId("testId");
		m.setType(MessType.SEQ);
		m.setOverdueTime((int)new GregorianCalendar().getTimeInMillis() / 1000 + 10000);
		waitArea.put("testId", m);
		q.setWaitArea(waitArea);
		queues.put(1, q);
	}
	
	@Override
	public Queue getQueue(Integer queueId) {
		return queues.get(queueId);
	}

	@Override
	public Map<Integer, Queue> getQueues() {
		return queues;
	}
	
	private boolean startAllThread(){
		return true;
	}
	
	private boolean stopAllThread(){
		return true;
	}

	@Override
	public void loadQueues() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void start() {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void stop() {
		// TODO Auto-generated method stub
		
	}
	
	
}
